package com.kl.websocket.customAppender;

import ch.qos.logback.classic.LoggerContext;
import org.slf4j.LoggerFactory;

public class AppendLogRegister {
    public static void register(){
        LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
        // 第二步：获取日志对象 （日志是有继承关系的，关闭上层，下层如果没有特殊说明也会关闭）
        ch.qos.logback.classic.Logger rootLogger = lc.getLogger("root");
        MyAppender myAppender = new MyAppender();
        myAppender.setContext(lc);
        myAppender.setName("myAppender");
        myAppender.start();
        rootLogger.addAppender(myAppender);
    }
}
